//
//  FYProxy1.m
//  MemoryManagerDemo
//
//  Created by FelixYin on 2020/4/11.
//  Copyright © 2020 FelixYin. All rights reserved.
//

#import "FYProxy1.h"

@interface FYProxy1 ()

@property (nonatomic,weak) id target;

@end

@implementation FYProxy1

/*
 NSProxy 中有两个方法：
 methodSignatureForSelector   返回方法签名
 forwardInvocation: 调用方法
 */

+ (instancetype)proxyWithTarget:(id)obj{
    //由于NSProxy 特殊，他是没有 init方法
    FYProxy1 *target = [FYProxy1 alloc];
    target.target= obj;
    return target;
}


- (NSMethodSignature *)methodSignatureForSelector:(SEL)sel{
    //调用NSObject中methodSignatureForSelector方法签名
    return [self.target methodSignatureForSelector:sel];
}

- (void)forwardInvocation:(NSInvocation *)invocation{
    [invocation invokeWithTarget:self.target];
}



@end
